library Wave17a initializer init requires LegacySystem, Wave16a, Wave15a

    private function ComponentVision takes nothing returns nothing
        local unit u = CreateUnit(GetEnumPlayer(),'e000',GetLocationX(udg_myloc),GetLocationY(udg_myloc),0.0)
        call UnitApplyTimedLife(u,'Bhwd',10.0)
        set u = null
    endfunction

    private function MarkingBeaconDrop takes nothing returns nothing
        local real x
        local real y
        local integer A = 1
        call ALICEText(30.0, "Marking Beacons have been airdropped." )
        loop
            exitwhen A>2
            if A==1 then
                set udg_myloc = GetRandomLocInRect(gg_rct_Town)
            else
                set udg_myloc = GetRandomLocInRect(gg_rct_Airfield)
            endif
            set x = GetLocationX(udg_myloc)
            set y = GetLocationY(udg_myloc)
            call DestroyEffect(AddSpecialEffect( "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",x,y ))
            call CreateItem('I00Y',x,y)
            if udg_Difficulty<4.0 then
                call PingMinimapEx(x, y, 30.0, 255, 0, 0, false)
                call SetCameraQuickPosition(x,y)
                call ForForce( udg_EchoCompany, function ComponentVision )
            endif
            call RemoveLocation(udg_myloc)
            call TriggerSleepAction(0.5)
            set A = A + 1
        endloop
    endfunction

    private function Wave17a takes nothing returns nothing
        local integer i = 1
        call SetMagnificentBastardsSpawnTriggersEnabled(false)
        call RemoveLocation(udg_CoreObjectivePoint)
        set udg_FollowObjective = false
        set udg_CoreObjective = gg_rct_Town
        set udg_CoreObjectivePoint = GetRectCenter(gg_rct_Town)
        set udg_CurrentWave = 17
        call GenericActions.execute()
        loop
            exitwhen i>udg_Players
            call UnitRemoveAbility( udg_Hero[GetConvertedPlayerId(ConvertedPlayer(udg_Sorted[i]))], 'A01A' )
            set i = i+1
        endloop
        call MBSet( udg_SquadStatus, 1, 1, "Objective : Secure Perimeter" )
        call ItemSpawnN('I00H',1) //XML-9C Shiva
        if udg_Players>5 and udg_SquadXP>40000 then
            call SetPopperExplosionControlEnabled(true)
            call RandomSpawn('u00U',2,GetRandomInt(0,udg_Spawn)) //Poppers
        endif
        call RandomSpawn('uabo',2,udg_InitialPlayers) //Flesh Composite
        call SpawnRectRandom(gg_rct_SpawnNorthWaterfall,Player(14),'u005',2+GetRandomInt(1,udg_Spawn))
        call SpawnRectRandom(gg_rct_SpawnTownEastCave,Player(14),'u005',2+GetRandomInt(1,udg_Spawn))
        call RandomSpawn('u004',1,udg_Players) //Wraith
        call RandomSpawn('n00C',1,2) //Female
        call RandomSpawn('u000',2,GetRandomInt(0,udg_Spawn)) //Futty
        call PolledWait(10.)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : Lots of casualties coming in from Tac Net." )
        call RandomSpawn('u00L',4,IMinBJ(5,udg_Players)) //Blink
        call GankMarine(Player(13),'n005',3+GetRandomInt(1,udg_Spawn),1600,2000)
        call GankMarine(Player(13),'n00N',3+GetRandomInt(1,udg_Spawn),1600,2000)
        call PolledWait(30.0*udg_Pace)
        call MultiboardSetTitleText( udg_SquadStatus, "Iron Hand : Target clusters of Class As with CAS." )
        call GeneralText(20.0, "|cffcd950cBattalion|r : We've got Close Air Support on standby. Designate targets for our birds with Marking Beacons." )
        if GetSecuredLandingZones()<=2 then
            call RandomSpawn('z002',3,udg_Spawn) //Slasher
        endif
        call PolledWait(10.)
        call MarkingBeaconDrop.execute()
        call PolledWait(10.)
        call MBSet( udg_SquadStatus, 1, 1, "Objective : Utilize CAS" )
        call QuestSetDescription(udg_CurrentOrders, "Provide targets for CAS elements. Neutralize all immediate threats. Due to limited aircraft in the vicinity, CAS should be used effectively against large groups of Class As. It is essential to account for the delay between a CAS order and the actual arrival of CAS when using the Marking Beacons." )
        call ALICEText(5.0, "|cff8b864eNew Objective|r : Utilize CAS to eliminate overwhelming threats." )
        call GankMarine(Player(13),'n005',3+GetRandomInt(1, udg_Spawn),1600,2000)
        call GankMarine(Player(13),'n00N',3+GetRandomInt(1, udg_Spawn),1600,2000)
        call PolledWait(40.0*udg_Pace)
        if udg_Players>5 and udg_SquadXP>40000 then
            call RandomSpawn('u00U',2,GetRandomInt(0,udg_Spawn)) //Poppers
        endif
        set udg_soundpath = "Sound\\Interface\\GlueScreenMeteorLaunch3.wav"
        call PlaySoundPath.execute()
        call GeneralText(15.0, "|cffcd950cTacAir|r : We have a special delivery for your guests. Just let us know where you want 'em." )
        call RandomSpawn('z002',1,2+udg_Spawn) //Slasher
        call GankMarine(Player(13),'n00D',2+GetRandomInt(1,udg_Spawn),1600,2000)
        call GankMarine(Player(13),'n005',3+GetRandomInt(1,udg_Spawn),1600,2000)
        call RandomSpawn('uabo',2,udg_Players) //Flesh Composite
        call PolledWait(40.0*udg_Pace)
        call GeneralText(10.0, "|cffcd950cCaptain Roth|r : Be advised. We've got visual of Flesh Composites, dozens of 'em." )
        call GankMarine(Player(13),'n00N',3+GetRandomInt(1,udg_Spawn),1600,2000)
        call SpawnRectRandom(gg_rct_SpawnWestCave,Player(14),'n00C',udg_InitialPlayers)
        if udg_SquadXP>20000 then
            call RandomSpawn('n016',3,udg_Spawn) //Invi Worm
        else
            call SpawnRectRandom(gg_rct_SpawnSouthWaterfall,Player(14),'n00A',1)
        endif
        call PolledWait(20.0*udg_Pace)
        set udg_soundpath = "Sound\\Interface\\GlueScreenMeteorLaunch3.wav"
        call PlaySoundPath.execute()
        call PolledWait(20.0*udg_Pace)
        call GankMarine(Player(14),'u005',2*udg_Spawn,1200,1800)
        call GankMarine(Player(14),'u005',2*udg_Spawn,1200,1800)
        set i = GetRandomInt(1,udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : Get them in a tight group before calling in CAS." )
        call PolledWait(5.)
        call StartSound(gg_snd_Thanatos)
        set udg_myloc = GetRandomLocInRect(udg_PlayerSpawnBoundary)
        set udg_Boss = CreateUnitAtLoc(Player(14),'U006',udg_myloc,0) //Thanatos Variant B
        call SuspendHeroXP(udg_Boss,true)
        call RemoveLocation(udg_myloc)
        call PolledWait(5.)
        call GeneralText(10.0, "|cffcd950cCaptain Roth|r : There's another Thanatos out there." )
        call PolledWait(5.0*udg_Pace)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : That thing is going to tear you a new asshole if it gets too close." )
        call GankMarine(Player(13),'n005',4+GetRandomInt(1,udg_Spawn),1600,2000)
        call GankMarine(Player(13),'n00D',2+GetRandomInt(1,udg_Spawn),1600,2000)
        call GankMarine(Player(14),'u005',2+udg_Spawn,1800,2000)
        call PolledWait(35.0*udg_Pace)
        call SetPopperExplosionControlEnabled(false)
        if udg_Players>0 then
            call ExecuteRegisteredFunction("Wave18a")
           // call Wave18a.execute()
        endif
    endfunction


    private function init takes nothing returns nothing
        call RegisterFunction("Wave17a", function Wave17a)
    endfunction

endlibrary